Running shell script from /Applications gives operation not permitted:

I have a shell script in a sub folder in /Applications/


When I run the script I get:


sh: operation not permitted: /Applications/SecuritySpy.app/Contents/Resources/English.lproj/Scripts/scpjr.ks h


OR


bash: /Applications/SecuritySpy.app/Contents/Resources/English.lproj/Scripts/scpjr.ks h: /bin/ksh: bad interpreter: Operation not permitted


OR

zsh: operation not permitted: /Applications/SecuritySpy.app/Contents/Resources/English.lproj/Scripts/scpjr.ks h


But it works if my shell is the ksh

ksh

[%m %T %d] /Applications/SecuritySpy.app/Contents/Resources/English.lproj/Scripts/scpjr.ks h $0


I have run xattr -d com.apple.quarantine on the directory and file but this makes no difference.


Any ideas ?

iMac (27-inch, Late 2012), OS X El Capitan (10.11.6)

Posted on Jul 30, 2016 5:02 AM

Reply
3 replies

Jul 30, 2016 2:58 PM in response to rccharles

No... The script runs fine from my home dir.. It does not matter what the hash bang is set to, I've even tried to make it a Perl script and running it using /usr/bin/env zsh etc.


The script just does not run in /Applications unless run the korn shell first as described in the post, this is a Mac OS X thing and it isn't a com.apple.quarantine thing..

Jul 31, 2016 12:40 PM in response to rocteur

The error "Operation not permitted" indicates a locked file or directory that your script is trying to operate on. The error "/bin/ksh: bad interpreter:" indicates that the script has control characters within the script and on the first line, more than likely carriage returns. When you run the script in ksh it is actuality failing, the $0 on the end is creating a new instance of the ksh shell thus hiding any error messages.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Running shell script from /Applications gives operation not permitted:

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.